package cn.tianyigps.tianyigpsgatherchecker.service;

import cn.tianyigps.tianyigpsgatherchecker.bean.EquipmentCheckModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.*;

@Service
public class GetCarNums {
    @Autowired
    EquipmentCheckModelService equipmentCheckModelService;
    @Autowired
    FindLicensePlate findLicensePlate;
    public HashSet getCarNumbers(EquipmentCheckModel equipmentCheckModel, int gatherTime, int radius) throws IOException {

        if (Optional.ofNullable(equipmentCheckModel.getGpsLatitude()).isPresent() && Optional.ofNullable(equipmentCheckModel.getGpsLongitude()).isPresent()) {
            Map<String, String> param = new HashMap<>(4);
            param.put("Latitude", equipmentCheckModel.getGpsLatitude().toString());
            param.put("Longitude", equipmentCheckModel.getGpsLongitude().toString());
            param.put("radius", String.valueOf(radius));
            param.put("gatherTime", gatherTime + "");
            //获取指定半径内，指定时间内停车的数量
            List<EquipmentCheckModel> list = equipmentCheckModelService.getGather(param);
            //获取车辆数（包含车牌号，或者车架号）
            return   findLicensePlate.findLicensePlate(list);

        }
        return  null;

    }
}
